﻿using Microsoft.IdentityModel.JsonWebTokens;
using Soul.IdentityServer.Models;
using Soul.IdentityServer.Validation;

namespace Hosting.Infrastructure
{
    public class PasswordCredentialsGrantValidator : IGrantValidator
    {
        public string GrantType => OpenIdConnectGrantTypes.Password;

        public Task ValidateAsync(TokenGrantContext context)
        {
            var identity = new System.Security.Claims.ClaimsIdentity(GrantType);
            identity.AddClaim(new System.Security.Claims.Claim(JwtRegisteredClaimNames.Sub, "1024"));
            context.Subject.AddIdentity(identity);
            return Task.CompletedTask;
        }
    }
}
